/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2024-06-30     WangJing       the first version
 */
#include "yolo.h"
#include "stdio.h"

#define DBG_TAG "yolo"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>

// 处理树莓派传来的数据包(数据包格式:{<类>:<坐标1>,<坐标2>}，例如{I:71,90})
YoloData_t yolo_dataParser(uint8_t * addr,int clear){
    YoloData_t yoloData = {0};

    if (sscanf((char*)addr, "{%c:%d,%d}", &yoloData.kind, &yoloData.x, &yoloData.y) == 3) {
        if(1 == clear)addr[0] = '\0';
    } else {
        // 解析失败，设置默认值或进行错误处理
        yoloData.kind = '\0';
        yoloData.x = -1;
        yoloData.y = -1;
    }

    return yoloData;
}


